require("./log-in.css");
//引入axios
const axios = require("axios");
window.addEventListener("load", function () {
	//获取方法
	function $(v) {
		return document.querySelector(v);
	}
	// 切换到注册页面
	$("#enter").addEventListener("click", function () {
		location.href = "./login.html";
	});
	let phonenmb = $("#id").value;
	let password = $("#password").value;
	$("button").addEventListener("click", function (e) {
		e.preventDefault();
		axios
			.post("http://fitness.h5.itsource.cn:3701/api/user/login", {
				account: phonenmb,
				password: password,
			})
			.then((v) => {
				if (v.data.errno === 0) {
					alert("欢迎回来");
					localStorage.setItem("token", v.data.data.token);
					location.href = "./index1.html";
				} else {
					alert("登录失败");
				}
			});
	});
});
